/*
**  libutl.h - header for libutl.c module
**  Copyright (C) 1999 Joachim Ott <ott@ardala.han.de>
**
**  This program is free software; you can redistribute it and/or modify
**  it under the terms of the GNU General Public License as published by
**  the Free Software Foundation; either version 2 of the License, or
**  (at your option) any later version.
**
**  This program is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**  GNU General Public License for more details.
**
**  You should have received a copy of the GNU General Public License
**  along with this program; if not, write to the Free Software
**  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
** $Id: libutl.h,v 1.1 2000/08/19 14:55:45 ott Exp $
*/

#ifndef h_libutl
#define h_libutl

#include "global.h"

/*-----------------------------------------------------------------------*/

#define S_TIP	struct TeilnehmerTip
#define S_TZ	struct TipZettel
#define S_T	struct Tips

S_TIP
{
	char *	name;		/* Tip-Name */
	int	pos [N_TEAMS];	/* Tip */
	S_TIP *	next;		/* naechster Tip */
	S_TIP *	prev;		/* vorheriger Tip */
	S_TZ *	tz;		/* Link zurueck zum Tipzettel */
};

S_TZ
{
	char *	name;		/* Name des Teilnehmers */
	int	n_tips;
	S_TIP *	tip;		/* Tip(s) des Teilnehmers */
	S_TZ *	next;		/* naechster Teilnehmer */
	S_TZ *	prev;		/* vorheriger Teilnehmer */
};

S_T
{
	char * 	einsatz;	/* Einsatz pro Tip (DM/Euro) */
	char *	geld;		/* Gewinnbetraege fuer die ersten N Leute */
	char *	geld0;		/* Gewinnbetraege fuer die ersten N Leute (Nulltip) */
	char *	akt_id;
	int	n_tz;		/* Anzahl Tipzettel (= Teilnehmer) */
	int	n_tips;		/* Anzahl Tips */
	int	tzn_max;	/* laengster Teilnehmername */
	int	tipn_max;	/* laengster Tipname */
	S_TZ *	first;		/* erster Tipzettel */
	S_TZ *	last;		/* letzter Tipzettel */
};

/*-----------------------------------------------------------------------*/

__BEGIN_DECLS

/* verfuegbare Aufrufe der BTM-Bibliothek */

extern char *	utl_fehler (void);

extern int	utl_read_teams   (const char *tabfile, char **to);

extern int	utl_read_newtipfile (const char *fn, S_T *tips);
extern int	utl_write_newtipfile (const char *fn, S_T *t);

#define UTL_READ_OK	0	/* Datei ohne Fehler gelesen */
#define UTL_READ_NOENT	1	/* Datei nicht gefunden */
#define UTL_READ_CRC	2	/* CRC-Fehler beim Lesen */
#define UTL_READ_ERROR	3	/* Fehler beim Lesen */

#define UTL_WRITE_OK	0
#define UTL_WRITE_RENAME	1
#define UTL_WRITE_OFAIL	2
#define UTL_WRITE_FAIL	3

extern int	utl_neuer_mitspieler (const char *name, S_T *tips);
extern void	utl_neuer_mitspielername (S_T *tips, const char *name, int);
extern void	utl_loesche_teilnehmer (S_T *tips, S_TZ *tz);
extern void	utl_loesche_alle_mitspieler (S_T *tips);
extern void	utl_verschiebe_mitspieler (S_T *Alt, S_T *Neu, S_TZ *n_tz);
extern void	utl_loesche_tip (S_T *tips, S_TZ *tz, S_TIP *tip);
extern int	utl_neuer_tip (S_T *tips, S_TZ *tz, const char *name, int *pos);
extern int	utl_neuer_tipname (S_TZ *tz, const char *name, int);
extern int	utl_pruefe_summen (S_T *tips);

extern char *	utl_pos_string (int *pos);
extern char *	utl_itoa (int n, int size);

extern void	AddMsg (char *);

__END_DECLS

/*-----------------------------------------------------------------------*/

#endif /* h_libutl */

/* libutl.h */
